<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>js瀑布流</title>
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <!-- 图片的宽度是统一固定的，但是由于高度不一样，第一行图片排满之后，
    新的图片会插入到第一排中高度最低的图片下面，并更新高度，如此循环，
    最终达到瀑布流式的效果 -->

  <!-- container容器用来存放box容器，一个box放一张图片 -->
  <div id="container">
      <!-- 根据自己的需求添加图片的数量 -->
    <div class="box">
      <div class="box-img"><img src="./img/1.jpg" alt=""></div>
    </div>
    <div class="box">
      <div class="box-img"><img src="./img/2.jpg" alt=""></div>
    </div>
    <div class="box">
      <div class="box-img"><img src="./img/3.jpg" alt=""></div>
    </div>
    <div class="box">
      <div class="box-img"><img src="./img/4.jpg" alt=""></div>
    </div>
    <div class="box">
      <div class="box-img"><img src="./img/5.jpg" alt=""></div>
    </div>
    <div class="box">
      <div class="box-img"><img src="./img/6.jpg" alt=""></div>
    </div>
    <div class="box">
      <div class="box-img"><img src="./img/7.jpg" alt=""></div>
    </div>
    <!-- <div class="box">
      <div class="box-img"><img src="./img/8.jpg" alt=""></div>
    </div> -->

    <!-- <div class="box">
      <div class="box-img"><img src="./img/1.jpg" alt=""></div>
    </div>
    <div class="box">
      <div class="box-img"><img src="./img/2.jpg" alt=""></div>
    </div>
    <div class="box">
      <div class="box-img"><img src="./img/3.jpg" alt=""></div>
    </div>
    <div class="box">
      <div class="box-img"><img src="./img/4.jpg" alt=""></div>
    </div>
    <div class="box">
      <div class="box-img"><img src="./img/5.jpg" alt=""></div>
    </div>
    <div class="box">
      <div class="box-img"><img src="./img/6.jpg" alt=""></div>
    </div>
    <div class="box">
      <div class="box-img"><img src="./img/7.jpg" alt=""></div>
    </div>
    <div class="box">
      <div class="box-img"><img src="./img/8.jpg" alt=""></div>
    </div>
    <div class="box">
      <div class="box-img"><img src="./img/1.jpg" alt=""></div>
    </div>
    <div class="box">
      <div class="box-img"><img src="./img/2.jpg" alt=""></div>
    </div>
    <div class="box">
      <div class="box-img"><img src="./img/3.jpg" alt=""></div>
    </div>
    <div class="box">
      <div class="box-img"><img src="./img/4.jpg" alt=""></div>
    </div>
    <div class="box">
      <div class="box-img"><img src="./img/5.jpg" alt=""></div>
    </div>
    <div class="box">
      <div class="box-img"><img src="./img/6.jpg" alt=""></div>
    </div>
    <div class="box">
      <div class="box-img"><img src="./img/7.jpg" alt=""></div>
    </div>
    <div class="box">
      <div class="box-img"><img src="./img/8.jpg" alt=""></div>
    </div> -->
  </div>

  <script type="text/javascript" src="waterfall.js">
    
  </script>
</body>
</html>
